﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RelationExpertSystem.Relation
{
    public class Step_Child : RelationBase
    {
        private static Step_Child _singleton = new Step_Child();
        public static Step_Child Instance
        {
            get { return _singleton; }
        }

        private Step_Child() { }

        public override bool IsRelated(Person a, Person b)
        {
            // b is a's Step_Child IFF a is not b's Parent and a is the Spouse of b's parent
            return (!Person.IsNull(b.Mother) && a != b.Mother &&
                    !Person.IsNull(b.Father) && a != b.Father &&
                    (a == b.Mother.Spouse || a == b.Father.Spouse));
            // ignore ex-spouse
            // skip Parent for now (can't use !KnownRelation anyway...)
        }

        public override IEnumerable<IRelation> GetDependencies()
        {
            return new HashSet<IRelation>(new IRelation[] { Spouse.Instance, Mother.Instance, Father.Instance });
        }
    }
}
